home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / CIncludesTool / modified version / put in scripts folder / MWCIncludesTool < prev    next >
Text File  |  1994-02-27  |  10KB  |  374 lines

  1. # Script For CIncludes Tool - by John Jeppson
  2. # modified for use with Metrowerks
  3.  
  4. Set Exit 0
  5. Set param 0
  6. Set toolStatus 0
  7.  
  8. If {#} == 2
  9.     If ("{1}" == "-f") || ("{1}" == "-F")
  10.         Set param 2
  11.     Else If ("{1}" == "-i") || ("{1}" == "-I")
  12.         Set param 3
  13.     Else If ("{1}" == "-d") || ("{1}" == "-D")    # Daniel Grassi
  14.         Set param 4
  15.     End
  16. Else
  17.     If {#} == 1
  18.         If ("{1}" == "-m") || ("{1}" == "-M")
  19.             Set param 1
  20.         End
  21.     End
  22. End
  23.  
  24. If {param} == 0
  25.     Alert "MWCIncludesTool - Usage : MWCIncludesTool [-f -m -i -d] SrchString ∂n ∂
  26.    -f  Locates SrchString∂n ∂
  27.    -m  Rebuilds the CIncludes identifier dictionary∂n ∂
  28.    -i  Reformats ∂"#include∂" statements in selection∂n ∂
  29.    -d  Displays the file declaring SrchString"
  30.  
  31. Else If {param} == 1
  32. ##    Find §:/∞/ "{Active}"
  33. ##    Find §Δ "{Active}"
  34. ##    Echo
  35.  
  36.     If ("{CIncludesCompiler}" == 'AppleCFront')
  37.         Set j "`Quote "{CIncludes}"`≈.h"
  38.         Begin
  39.             Set SrchList ""
  40.             Set j "`Quote "{CIncludes}"`≈.h"
  41.             If ("`Exists -f {j}`" != "")
  42.                 Set SrchList "`Quote "{CIncludes}"`≈.h"
  43.             Else
  44.                 Set SrchList ""
  45.             End  # If Exists
  46.         End ≥ Dev:Null
  47.         For j in `Files -fr -d -r -o "{CIncludes}"`
  48.             If ("`Exists -f "{j}"≈.h`" != "")
  49.                 Set j "`Quote "{j}"`"
  50.                 Set SrchList "{SrchList} {j}≈.h"
  51.             End  # If Exists
  52.         End ∑ Dev:Null # For j
  53.         If ({MACPlusIncludes} != "")
  54.             Begin
  55.                 Set SrchList2 ""
  56.                 Set j "`Quote "{MACPlusIncludes}"`≈.h"
  57.                 If ("`Exists -f {j}`" != "")
  58.                     Set SrchList2 "`Quote "{MaCPLusIncludes}"`≈.h"
  59.                 Else
  60.                     Set SrchList2 ""
  61.                 End  # If Exists
  62.             End ≥ Dev:Null
  63.             For j in `Files -fr -d -r -o "{MACPlusIncludes}"`
  64.                 If ("`Exists -f "{j}"≈.h`" != "")
  65.                     Set j "`Quote "{j}"`"
  66.                     Set SrchList2 "{SrchList2} {j}≈.h"
  67.                 End  # If Exists
  68.             End  ∑ Dev:Null # For j
  69.             CIncludesCode -m `Files -fr {SrchList} {SrchList2}`
  70.             Unset SrchList2
  71.         Else
  72.             CIncludesCode -m `Files -fr {SrchList}`
  73.         End  # If
  74.     Else
  75.         If ("{CIncludesCompiler}" == 'SymantecC++')
  76.             Begin
  77.                 Set SrchList ""
  78.                 Set j "`Quote "{SCIncludes}"`≈.h"
  79.                 If ("`Exists -f {j}`" != "")
  80.                     Set SrchList "`Quote "{SCIncludes}"`≈.h"
  81.                 Else
  82.                     Set SrchList ""
  83.                 End  # If Exists
  84.             End ≥ Dev:Null
  85.             For j in `Files -fr -d -r -o "{SCIncludes}"`
  86.                 If ("`Exists -f "{j}"≈.h`" != "")
  87.                     Set j "`Quote "{j}"`"
  88.                     Set SrchList "{SrchList} {j}≈.h"
  89.                 End  # If Exists
  90.             End ∑ Dev:Null # For j
  91.             If ({MASCPlusIncludes} != "")
  92.                 Begin
  93.                     Set SrchList2 ""
  94.                     Set j "`Quote "{MASCPlusIncludes}"`≈.h"
  95.                     If ("`Exists -f {j}`" != "")
  96.                         Set SrchList2 "`Quote "{MASCPlusIncludes}"`≈.h"
  97.                     Else
  98.                         Set SrchList2 ""
  99.                     End  # If Exists
  100.                 End ≥ Dev:Null
  101.                 For j in `Files -fr -d -r -o "{MASCPlusIncludes}"`
  102.                     If ("`Exists -f "{j}"≈.h`" != "")
  103.                         Set j "`Quote "{j}"`"
  104.                         Set SrchList2 "{SrchList2} {j}≈.h"
  105.                     End  # If Exists
  106.                 End  ∑ Dev:Null # For j
  107.                 CIncludesCode -m `Files -fr {SrchList} {SrchList2}`
  108.                 Unset SrchList2
  109.             Else
  110.                 CIncludesCode -m `Files -fr {SrchList}`
  111.             End  # If
  112.         Else
  113.             If ("{CIncludesCompiler}" == 'MetrowerksC++')
  114.                 Begin
  115.                     Set SrchList ""
  116.                     Set j "`Quote "{MWIncludes}"`≈.h"
  117.                     If ("`Exists -f {j}`" != "")
  118.                         Set SrchList "`Quote "{MWIncludes}"`≈.h"
  119.                     Else
  120.                         Set SrchList ""
  121.                     End  # If Exists
  122.                 End ≥ Dev:Null
  123.                 For j in `Files -fr -d -r -o "{MWIncludes}"`
  124.                     If ("`Exists -f "{j}"≈.h`" != "")
  125.                         Set j "`Quote "{j}"`"
  126.                         Set SrchList "{SrchList} {j}≈.h"
  127.                     End  # If Exists
  128.                 End ∑ Dev:Null # For j
  129.                 If ({MAMCPlusIncludes} != "")
  130.                     Set j "`Quote "{MAMCPlusIncludes}"`≈.h"
  131.                         Begin
  132.                             Set SrchList2 ""
  133.                             Set j "`Quote "{MAMCPlusIncludes}"`≈.h"
  134.                             If ("`Exists -f {j}`" != "")
  135.                                 Set SrchList2 "`Quote "{MAMCPlusIncludes}"`≈.h"
  136.                             Else
  137.                                 Set SrchList2 ""
  138.                             End  # If Exists
  139.                         End ≥ Dev:Null
  140.                     For j in `Files -fr -d -r -o "{MAMCPlusIncludes}"`
  141.                         If ("`Exists -f "{j}"≈.h`" != "")
  142.                             Set j "`Quote "{j}"`"
  143.                             Set SrchList2 "{SrchList2} {j}≈.h"
  144.                         End  # If Exists
  145.                     End  ∑ Dev:Null # For j
  146.                     CIncludesCode -m `Files -fr {SrchList} {SrchList2}`
  147.                     Unset SrchList2
  148.                 Else
  149.                     CIncludesCode -m `Files -fr {SrchList}`
  150.                 End  # If
  151.             End  # If
  152.         End  # If
  153.     End  # If
  154.  
  155.     Unset SrchList
  156.     Set toolStatus "{Status}"
  157.     Beep 2C,20,128
  158.  
  159. Else If {param} == 2
  160. ##    Mark -y § x162534 "{Active}"
  161.  
  162.     Set str "{2}"
  163.     CIncludesCode -v "{str}"
  164.     Set toolStatus "{Status}"
  165.  
  166.     If {toolStatus} == 0
  167. ##        Find • "{Active}"
  168. ##       Find Δ/#include/ "{Active}"                  # Daniel Grassi
  169. ##        CIncludesCode -f "{str}"
  170. ##        Set toolStatus "{Status}"
  171. ## replacement (different functionality) from above
  172.     Set counter 1
  173.     For i in `CIncludesCode -d "{str}"`
  174.         If {counter} == 1
  175.             Echo "∂#include ∂<{i}∂>" ∑∑ Dev:StdErr
  176.             Beep 1C
  177.             Set counter 2
  178.         End  # If {counter}
  179.     End  # For i
  180. End  # If {ToolStatus}
  181.     
  182. ##    Find x162534 "{Active}"
  183. ##    Unmark x162534 "{Active}"
  184.  
  185. Else If {param} == 3
  186. ##    CIncludesCode -i "{Active}.§"
  187. ##    Set toolStatus "{Status}"
  188.     Alert "{0} :∂n∂noption -i (reformating selected include statements) is not supported in Metrowerks."
  189.  
  190. Else If {param} == 4                                # Daniel Grassi
  191.         Set str "{2}"
  192.         CIncludesCode -v "{str}"
  193.         Set toolStatus "{Status}"
  194.  
  195.         If {toolStatus} == 0
  196.             Set counter 1
  197.             For i in `CIncludesCode -d "{str}"`
  198.                 If {counter} == 1
  199.                 
  200.                     If ("{CIncludesCompiler}" == 'AppleCFront')
  201.                         Set SrchList "`Quote "{CIncludes}{i}"`"
  202.                         For j in `Files -fr -d -r "{CIncludes}"`
  203.                             Set j "`Quote "{j}"`"
  204.                             Set SrchList "{SrchList} {j}{i}"
  205.                         End ∑ Dev:Null # For j
  206.                         
  207.                         For j in {SrchList}
  208. ##                            Open -r "{j}" ∑∑ Dev:Null
  209.                             Set j "`Quote "{j}"`"
  210.                             If ("`Exists -f {j}`" != "")
  211.                                 MWFile {j} ∑∑ Dev:Null
  212.                                 If ({Status} == 0)
  213.                                     Set FoundIt 1
  214.                                     Set HeaderName "{j}"
  215.                                     Break
  216.                                 End  # If {Status}
  217.                             End  # If Exists
  218.                         End ∑ Dev:Null # For j
  219.                         Unset SrchList
  220.     
  221.                         If ({FoundIt} == 0)
  222.                             Set SrchList "`Quote "{MACPlusIncludes}{i}"`"
  223.                             For j in `Files -fr -d -r "{MACPlusIncludes}"`
  224.                                 Set j "`Quote "{j}"`"
  225.                                 Set SrchList "{SrchList} {j}{i}"
  226.                             End ∑ Dev:Null # For j
  227.                             For j in {SrchList}
  228. ##                                Open -r "{j}" ∑∑ Dev:Null
  229.                                 Set j "`Quote "{j}"`"
  230.                                 If ("`Exists -f {j}`" != "")
  231.                                     MWFile {j} ∑∑ Dev:Null
  232.                                     If ({Status} == 0)
  233.                                         Set FoundIt 1
  234.                                         Set HeaderName "{j}"
  235.                                         Break
  236.                                     End  # If {Status}
  237.                                 End  # If Exists
  238.                             End ∑ Dev:Null  # For j
  239.                             Unset SrchList
  240.                             If ({FoundIt} == 0)
  241.                                 Alert "Unable to open the header file {i}"
  242.                             End  # If {Status}
  243.                         End  # If {Status}
  244.                     Else
  245.                         If ("{CIncludesCompiler}" == 'SymantecC++')
  246.                             Set SrchList "`Quote "{SCIncludes}{i}"`"
  247.                             For j in `Files -fr -d -r "{SCIncludes}"`
  248.                                 Set j "`Quote "{j}"`"
  249.                                 Set SrchList "{SrchList} {j}{i}"
  250.                             End ∑ Dev:Null # For j
  251.                             
  252.                             For j in {SrchList}
  253. ##                                Open -r "{j}" ∑∑ Dev:Null
  254.                                 Set j "`Quote "{j}"`"
  255.                                 If ("`Exists -f {j}`" != "")
  256.                                     MWFile {j} ∑∑ Dev:Null
  257.                                     If ({Status} == 0)
  258.                                         Set FoundIt 1
  259.                                         Set HeaderName "{j}"
  260.                                         Break
  261.                                     End  # If {Status}
  262.                                 End  # If Exists
  263.                             End ∑ Dev:Null # For j
  264.                             Unset SrchList
  265.         
  266.                             If ({FoundIt} == 0)
  267.                                 Set SrchList "`Quote "{MASCPlusIncludes}{i}"`"
  268.                                 For j in `Files -fr -d -r "{MASCPlusIncludes}"`
  269.                                     Set j "`Quote "{j}"`"
  270.                                     Set SrchList "{SrchList} {j}{i}"
  271.                                 End ∑ Dev:Null # For j
  272.                                 For j in {SrchList}
  273. ##                                    Open -r "{j}" ∑∑ Dev:Null
  274.                                     Set j "`Quote "{j}"`"
  275.                                     If ("`Exists -f {j}`" != "")
  276.                                         MWFile {j} ∑∑ Dev:Null
  277.                                         If ({Status} == 0)
  278.                                             Set FoundIt 1
  279.                                             Set HeaderName "{j}"
  280.                                             Break
  281.                                         End  # If {Status}
  282.                                     End  # If Exists
  283.                                 End ∑ Dev:Null  # For j
  284.                                 Unset SrchList
  285.                                 If ({FoundIt} == 0)
  286.                                     Alert "Unable to open the header file {i}"
  287.                                 End  # If {Status}
  288.                             End  # If {Status}
  289.                         Else
  290.                             If ("{CIncludesCompiler}" == 'MetrowerksC++')
  291.                                     Set SrchList "`Quote "{MWIncludes}{i}"`"
  292.                                     For j in `Files -fr -d -r "{MWIncludes}"`
  293.                                         Set j "`Quote "{j}"`"
  294.                                         Set SrchList "{SrchList} {j}{i}"
  295.                                     End # For j
  296.  
  297.                                     For j in {SrchList}
  298. ##                                        Open -r "{j}" ∑∑ Dev:Null
  299.                                         Set j "`Quote "{j}"`"
  300.                                         If ("`Exists -f {j}`" != "")
  301.                                             MWFile {j} ∑∑ Dev:Null
  302.                                             If ({Status} == 0)
  303.                                                 Set FoundIt 1
  304.                                                 Set HeaderName "{j}"
  305.                                                 Break
  306.                                             End  # If {Status}
  307.                                         End  # If Exists
  308.                                     End ∑ Dev:Null # For j
  309.                                     Unset SrchList
  310.                 
  311.                                     If ({FoundIt} == 0)
  312.                                         Set SrchList "`Quote "{MAMCPlusIncludes}{i}"`"
  313.                                         For j in `Files -fr -d -r "{MAMCPlusIncludes}"`
  314.                                             Set j "`Quote "{j}"`"
  315.                                             Set SrchList "{SrchList} {j}{i}"
  316.                                         End ∑ Dev:Null # For j
  317.                                         For j in {SrchList}
  318. ##                                            Open -r "{j}" ∑∑ Dev:Null
  319.                                             Set j "`Quote "{j}"`"
  320.                                             If ("`Exists -f {j}`" != "")
  321.                                                 MWFile  {j} ∑∑ Dev:Null
  322.                                                 If ({Status} == 0)
  323.                                                     Set FoundIt 1
  324.                                                     Set HeaderName "{j}"
  325.                                                     Break
  326.                                                 End  # If {Status}
  327.                                             End  # If Exists
  328.                                         End ∑ Dev:Null  # For j
  329.                                         Unset SrchList
  330.                                         If ({FoundIt} == 0)
  331.                                             Alert "Unable to open the header file {i}"
  332.                                         End  # If {Status}
  333.                                     End  # If {Status}
  334.                                 End  # If
  335.                             End  # If
  336.                         End  # If
  337.  
  338.                     Set counter 2
  339.                 Else
  340. ##                      Find •!{i} "{Active}"
  341. ##                    Find \{str}\ "{Active}" ∑∑ Dev:Null
  342.                     Set HeaderName "`Quote {HeaderName}`"
  343.                     Set LineNo "`FilePosToLine {HeaderName} "{i}"`"
  344.                     RMetrowerks line "{LineNo}"
  345.                 End
  346.             End
  347.             If ("{i}" == "")
  348.                 Set toolStatus 4                    # new - signal that no identifiers were found
  349.             Else
  350.                 Set toolStatus "{Status}"
  351.             End  # If {i}
  352.         End
  353. End
  354.  
  355.  
  356. If {toolStatus}
  357.     If {toolStatus} == '1'
  358.         Alert 'Bad parameters to "MWCIncludesTool"'    # won't occur here
  359.     Else If {toolStatus} == '2'
  360.         Alert 'Invalid Identifier!'
  361.     Else If {toolStatus} == '3'
  362.         If ({param} == 2) || (param} == 3)
  363.             Alert 'Unable to load database resource!'
  364.         Else
  365.             Alert 'Out of memory error!'
  366.         End
  367.     Else If {toolStatus} == '4'
  368.         Alert 'Identifier not found in CIncludes!'
  369.     Else
  370.         Alert "Unknown CIncludes error return value ({toolStatus})."
  371.     End
  372. End
  373.  
  374. # end of MWCIncludesTool